import axios from "axios";

// '正常交货', '商家少货', '商家损货', '用户退货', '运输少货', '运输损货'
// export const CheckResult = [
//     {key: 1, label: '正常交货', value: '正常交货'},
//     {key: 2, label: '商家少货', value: '商家少货'},
//     {key: 3, label: '商家损货', value: '商家损货'},
//     {key: 4, label: '用户退货', value: '用户退货'},
//     {key: 5, label: '运输少货', value: '运输少货'},
//     {key: 6, label: '运输损货', value: '运输损货'},
// ]

export const getDriversList = (callback) => {
    axios.get('/driver').then((response) => {
        callback(response.data);
    });
}

export const getDriver = (id, callback) => {
    axios.get('/driver/' + id).then((response) => {
        callback(response.data)
    })
}

export const deleteDriver = (id, callback) => {
    axios.delete('/driver/' + id).then((response) => {
        callback(response.data);
    });
}

export const updateDriver = (driverData, callback) => {
    axios.put('/driver/' + driverData.did, driverData).then((response) => {
        callback(response.data ? 1 : 0);
    })
}

export const createDriver = (driverData, callback) => {
    axios.post('/driver', driverData).then((response) => {
        callback(response.data ? 1 : 0)
    })
}

export const findIdByUsername = (username, callback) => {
    axios.get('/driver/id/' + username).then((response) => {
        callback(response.data);
    })
}

export const driverCheckOut = (form, callback) => {
    axios.post('/driver/checkout', null, {params: form}).then((response) => {
        callback(response.data ? 1 : 0)
    })
}